package com.acme.bankapp.domain.bank;

public class CheckingAccount extends SavingsAccount implements Account{
	private double overdraft;
	public CheckingAccount(double amount) {
		super(amount);
	}

	public CheckingAccount(double amount, double overdraft) {
		super(amount);
		if (overdraft<0){
			System.out.println("Error creating account (negative overdraft)");
		} else {
			this.setOverdraft(overdraft);
		}

	}

	@Override
	public boolean withdraw(double amount) {
		if (this.balance >= amount){
			this.balance -= amount;
		} else {
			this.setOverdraft(this.getOverdraft() - amount);
			System.out.println("Error in method withdraw, class Account! (amount has negative value)");
		}
		return true;
	}

	public double getOverdraft() {
		return overdraft;
	}

	public void setOverdraft(double overdraft) {
		this.overdraft = overdraft;
	}
	public double maximumAmountToWithdraw(){
		return (this.balance + this.overdraft);
	}
	
}
